home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / comm / term / GetFFRange3_2.rexx < prev    next >
OS/2 REXX Batch file  |  1993-04-07  |  7KB  |  244 lines

  1. /* ARexx script to get a range of FF disks from ftp site */
  2.  
  3. /* THIS CODE NEEDS MODIFICATION (PERSONALIZATION) TO WORK FOR YOU!! */
  4.  
  5. /* Modify the variables below (where indicated--search for "/***" to get
  6.    there quickly).  The delete the lines below that section that abort
  7.    this script until you have made these adjustments.
  8.    READ THE NOTE BELOW.
  9. */
  10.  
  11. /* Written by
  12.       Nickey MacDonald  (i6t4@jupiter.sun.csd.unb.ca)
  13.       February 24, 1993 - First released to public (Term 2.4a version)
  14.       April 2, 1993     - Updated for Term 3.1
  15.       April 7, 1993     - Updated for Term 3.2
  16.  
  17.    This script is written in AREXX for the AREXX port of TERM (3.2).
  18.     This should also work with TERM 3.1 as well (but not versions before
  19.    that) and it has a fix or two to make it work correctly.  (As I said
  20.    in the 3.1 version, I could not get TERM 3.1 to work correctly and
  21.    so I had trouble testing it.  It seems to work okay on TERM 3.2, so I
  22.    assume it would also work with a well working copy of 3.1 (if there
  23.    ever was one :-) ) )
  24.  
  25.    I use the CSH shell (on my Unix account) and there is at least
  26.    one dependancy in this code on that fact...  (The line that checks
  27.    for and creates the "WHEREDIR")
  28.  
  29.    **** NOTE WELL ****
  30.  
  31.    When this script exits from AREXX (like if you cancle one
  32.    of the disk number requesters or it completes normally, etc.) TERM
  33.    seems to wait indefinately (with a busy mouse pointer) for the AREXX
  34.    command to come back, although the output window closed.
  35.    (There used to be a 'Hit RETURN to continue prompt there...' it
  36.    appears to be lost in TERM 3.1).
  37.  
  38.    I have added a requestor (it is fixed since the 3.1 version) if there
  39.    is a timeout on the wait during the transfer of one of the FF disk
  40.    dirs (this type of code should be added in other places, but odds are
  41.    this is the most critical location if you have *really* slow links).
  42.    If will offer you the choice of "Keep waiting", "Skip the current wait"
  43.    (forge on as if the last wait had be satisfied) or "Quit" the script.
  44.    I was leary of adding anything to prevent the script form being
  45.    completely automatic, but I felt that in this case, if you timeout after
  46.    10 minutes, its probably failed anyway... and so I added it...
  47.  
  48.    ***  End Note ***
  49.  
  50.    This script was written to work with the ux1.cso.uiuc.edu anonymous
  51.    ftp archive of the Fred Fish Disks.  Its directories are as follows:
  52.  
  53.       /amiga
  54.          /fishdoc
  55.             /f3
  56.                Contents.3xx
  57.             /f4
  58.                Contents.4xx
  59.             /fy
  60.                Contents.yxx
  61.          /fish
  62.             /f5
  63.                /ff5xx
  64.                   *.lzh
  65.             /f6
  66.                /f6xx
  67.                   *.lzh
  68.             /fy
  69.                /fyxx
  70.                   *.lzh
  71.  
  72.    This script should be easily modified to handle another site with a
  73.    similar organization...  especially if its just changing a few of the
  74.    defined variables at the start.
  75. */
  76.  
  77. /*** Some configurable values - You will have to change some of these ***/
  78. /*** Probably at least the last three                                 ***/
  79. FTPSITE='ux1.cso.uiuc.edu'                /* The site to use */
  80. DOCDIR='/amiga/fishdoc'                   /* Where the contents files are */
  81. DISKDIR='/amiga/fish'                     /* Where the fish disks are */
  82. TIMEOUT='SEC 600'                         /* How long to WAIT (10 min) */
  83. ANONPWD='dumb@user'                       /* Mail address - Anon ftp pass */
  84. USERPROMPT='%'                            /* part of users csh prompt */
  85. WHEREDIR='/tmp/fish'                      /* Where to put fish disks */
  86.  
  87. /* Remove these lines (2 comment lines, SAY and exit) once you */
  88. /* personalize the above values */
  89. SAY 'You need to modify (personalize) this AREXX program...'
  90. exit
  91.  
  92. /* Allow results to be returned */
  93. OPTIONS RESULTS
  94.  
  95. ADDRESS TERM
  96.  
  97. SAY 'What range of FF disks do you want to fetch?'
  98.  
  99. /* Get starting disk number */
  100. RESULT=""
  101. 'REQUESTNUMBER PROMPT "Starting FF disk number?"'
  102.  
  103. if RC ~= 0 then
  104. do
  105.    SAY 'You must enter the starting disk number.'
  106.    exit
  107. end
  108.  
  109. startval=RESULT
  110.  
  111. /* Get ending disk number */
  112. RESULT=""
  113. 'REQUESTNUMBER PROMPT "Ending FF disk number?"'
  114.  
  115. if RC ~= 0 then
  116. do
  117.    SAY 'You must enter the endinf disk number.'
  118.    exit
  119. end
  120.  
  121. endval=RESULT
  122.  
  123. /* Lets make sure its worth starting... */
  124. IF startval > endval then
  125. do
  126.    SAY 'Start disk number must be less than end disk number!'
  127.    exit
  128. end
  129.  
  130. SAY 'Getting FF disks' startval 'to' endval'...'
  131.  
  132. 'TIMEOUT' TIMEOUT
  133.  
  134. /* Get into ftp */
  135. SAY 'Starting ftp...'
  136. 'SEND' 'if ( ! -d' WHEREDIR ') mkdir' WHEREDIR'\r'
  137. 'WAIT' USERPROMPT
  138. 'SEND' 'cd' WHEREDIR'\r'
  139. 'WAIT' USERPROMPT
  140. 'SEND' 'ftp -n\r'
  141. 'WAIT ftp>'
  142.  
  143. /* Connect to host */
  144. SAY 'Connecting...'
  145. 'SEND' 'open' FTPSITE'\r'
  146. 'WAIT ftp>'
  147. 'SEND' 'user anonymous\r'
  148. 'WAIT pass'
  149. 'SEND' ANONPWD'\r'
  150. 'WAIT ftp>'
  151.  
  152. /* Set mode */
  153. SAY 'Setting up ftp...'
  154. 'SEND' 'bin\r'
  155. 'WAIT ftp>'
  156. 'SEND' 'prompt\r'
  157. 'WAIT ftp>'
  158. 'SEND' 'hash\r'
  159. 'WAIT ftp>'
  160.  
  161. /* Get the contents files */
  162. SAY 'Getting contents files...'
  163. 'SEND' 'cd' DOCDIR'\r'
  164. 'WAIT ftp>'
  165.  
  166. do dnum=startval to endval
  167.    SAY '   Getting Contents.' || dnum || '...'
  168.    ddir='f' || TRUNC(dnum/100)
  169.    'SEND' 'cd' ddir '\r'
  170.    'WAIT ftp>'
  171.    'SEND' 'get Contents.' || dnum '\r'
  172.    'WAIT ftp>'
  173.    'SEND' 'cd ..\r'
  174.    'WAIT ftp>'
  175. end
  176.  
  177. /* Get the directories */
  178. SAY 'Getting FF disks by dir...'
  179. 'SEND' 'cd' DISKDIR'\r'
  180. 'WAIT ftp>'
  181.  
  182. do dnum=startval to endval
  183.    ddir='f' || TRUNC(dnum/100)
  184.    dname='ff' || dnum
  185.  
  186.    SAY '   Getting' dname'...'
  187.    'SEND' 'cd' ddir '\r'
  188.    'WAIT ftp>'
  189.  
  190.    'SEND' '!mkdir 'dname'\r'
  191.    'WAIT ftp>'
  192.    'SEND' 'lcd 'dname'\r'
  193.    'WAIT ftp>'
  194.    'SEND' 'cd 'dname'\r'
  195.    'WAIT ftp>'
  196.  
  197.    'SEND' 'mget *\r'
  198.    waitlp=0
  199.    do while waitlp=0
  200.       'WAIT ftp>'
  201.       if RC ~= 0 then
  202.       do
  203.          'REQUESTRESPONSE' 'OPTIONS "Wait Again|Skip|No" PROMPT "Timeout waiting for files... Continue?"'
  204.          if RC ~= 0 then exit
  205.          if RESULT = 2 then waitlp=1
  206.       end
  207.       else waitlp=1
  208.    end
  209.  
  210.    'SEND' 'cd ../..\r'
  211.    'WAIT ftp>'
  212.    'SEND' 'lcd ..\r'
  213.    'WAIT ftp>'
  214. end
  215.  
  216. /* All done finish up */
  217. SAY 'All done... quitting ftp.'
  218. 'SEND ' 'close\r'
  219. 'WAIT ftp>'
  220. 'SEND' 'quit\r'
  221. 'WAIT' USERPROMPT
  222.  
  223. /* Create an LHA archive
  224. SAY 'Archiving the directories...'
  225. 'SEND' 'lha c fishes' || startval || '-' || endval || '.lzh'
  226. do dnum=startval to endval
  227.    'SEND' ' ff' || dnum
  228. end
  229. 'SEND' '\r'
  230. 'WAIT' USERPROMPT
  231. */
  232.  
  233. /* Create LHA archive archives
  234. SAY 'Archiving the directories...'
  235. do dnum=startval to endval
  236.    'SEND' 'lha c ' || dnum '.lzh ' || dnum '\r'
  237.    'WAIT' USERPROMPT
  238. end
  239. */
  240.  
  241. SAY 'Macro exiting.'
  242.  
  243. exit
  244.